home *** CD-ROM | disk | FTP | other *** search
- Path: tst.hk.super.net!moscow
- From: moscow@news.hk.super.net (Peter Alexander Schindler)
- Newsgroups: comp.lang.c++
- Subject: Access COM port in MSVC++4.0
- Date: 26 Feb 1996 04:00:10 GMT
- Organization: Hong Kong Supernet
- Message-ID: <4grb8a$kaf@tst.hk.super.net>
- NNTP-Posting-Host: is3.hk.super.net
- X-Newsreader: TIN [version 1.2 PL2]
-
- Has anybody tried to access COM ports using the API in MSVC++4.0? I have
- been having troubles using the WriteFile() function. The code I write is
- like this:
-
- HANDLE hCom;
- char *buffer = "xxx";
- LPDWORD lpNumOfBytesWritten;
-
- hCom = CreateFile("COM2", GENERIC_READ|GENERIC_WRITE
- 0, NULL , OPEN_EXISTING, 0, NULL);
-
- /* check error here, and things are ok */
- /* set comm parameters */
-
- WriteFile(hCom, (LPCVOID)&buffer, sizeof(buffer),
- lpNumOfBytesWritten, NULL);
-
- The error ERROR_INVALID_PARAMETER results in the call to WriteFile().
- Can anybody offer me some hints? Thanks in advance.
-
-
- Rgds,
- Winnie
-
-
-